export function gitInit() {
  function getFolderInfo(baseDir) {
    return new Promise((resolve) => {
      window.api.git.getInstance(baseDir)
      window.electron.ipcRenderer.on('git-check-status-finish', (events, resp) => {
        resolve(resp)
      })
      window.electron.ipcRenderer.on('git-need-init', () => {
        resolve(null)
      })
    })
  }

  function initDir({ url, username, email, baseDir }) {
    return new Promise((resolve) => {
      window.api.git.initDir({ url, username, email, baseDir })
      window.electron.ipcRenderer.on('git-init-finish', () => {
        resolve()
      })
    })
  }
  function watchAndSync(repo) {
    window.api.git.watchAndSync(repo)
  }

  return { getFolderInfo, initDir , watchAndSync}
}
